var handleShibei = function(number,inputs){

  let shibei = inputs;
  let target = new Array(shibei.length).fill(0)

  let res = []
  let set = new Set();
  for(let i=0;i<shibei.length;i++){
    res[i] = i;
  
  }

  console.log(res)
  function ann(s=0,arr = []){

    if(s===arr.length){
      let temps = [];
      for(let i=0;i<arr.length;i++){
        temps[i] = arr[res[i]]

        console.log(temps)
        set.add(temps.join(""))
        //console.log(set)
      }
    }else if(s<arr.length){

     
      for(let i=0;i<arr.length;i++){
        if(target[i]===0){
          res[s] =i;
          target[i] =1;
          ann(s+1,arr);
          target[i] = 0;
        }
      }

    }

  }
  ann(0,shibei)
  res = [...set].sort()
  //res.forEach((v)=>console.log(v))

}

var number =3;
var inputs = ['a','b','c']

handleShibei(number,inputs)